package com.swyc.osschat.Test.StreamTest.Controller.Stream;

import java.util.List;

import com.swyc.osschat.Test.LambdaTest.Bean.Student;

/**
 * java8 stream接口终端操作 count，anyMatch，allMatch，noneMatch
 * @author zhaol@yunrong.cn
 * @version V2.1
 * @since 2.1.0 2019/8/9 18:05
 */
public class MatchTest {
    public static void main(String[] args) {
        List<Student> students = Student.generateData();
        //todo java8 stream接口终端操作 count，anyMatch，allMatch，noneMatch
        /*anyMatch表示，判断的条件里，任意一个元素成功，返回true*/
        boolean a = students.stream().anyMatch(FilterTest::isAdult);
        /*allMatch表示，判断条件里的元素，所有的都是，返回true*/
        boolean b = students.stream().allMatch(FilterTest::isAdult);
        /*noneMatch跟allMatch相反，判断条件里的元素，所有的都不是，返回true*/
        boolean c = students.stream().noneMatch(FilterTest::isAdult);
        System.out.println("dasdasd");
    }
}
